package com.demos.springcloud.gateway05_custLocalFilter.config;

import com.demos.springcloud.gateway05_custLocalFilter.filters.PostGateWayFilter;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RouteConfig {
    @Bean
    public RouteLocator routeLocator(RouteLocatorBuilder routeLocatorBuilder) {
        return routeLocatorBuilder
                .routes()
                .route("way2", predicateSpec -> predicateSpec
                        .path("/post/**")
                        .filters(gatewayFilterSpec -> gatewayFilterSpec.filter(new PostGateWayFilter()))
                        .uri("lb://postprovider"))
                .build();
    }
}
